#ifndef RAY_TRACE_THREAD_H_
#define RAY_TRACE_THREAD_H_

#include "Thread.h"

class Scene;
class RayTracer;
class Camera;


class RayTraceThread : public Thread
{
public:
    RayTraceThread(Scene* s, RayTracer* rt, Camera* cam,
                    int startX, int finishX, int startY, int finishY) :
    m_scene(s), m_rt(rt), m_cam(cam),
    m_startX(startX),m_startY(startY),
    m_finishX(finishX), m_finishY(finishY), m_shouldWait(false)
    {
        m_event = CreateEvent(0,0,0,0);
    }
    virtual void vRun(){vProcess();}
    virtual void vProcess();
    virtual void vPause()
    {
        m_shouldWait = true;

    }
    virtual void vStop()
    {
        m_tActive = false;
    }
    virtual void vResume()
    {
        m_shouldWait = false;
        SetEvent(m_event);
    }
    virtual bool vHasFinished()
    {
        return !m_tActive;
    }
    virtual int WaitForFinish()
    {
        m_tActive = false;
        return GetExitCode();
    }       
    void AntiAlias();

private:
    int m_startX;
    int m_finishX;
    int m_startY;
    int m_finishY;
    RayTracer*  m_rt;
    Scene*      m_scene;
    Camera*     m_cam;
    HANDLE m_event;
    bool m_shouldWait;
};

#endif